package cn.fl.insurance.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.insurance.condition.InsCompTypRQueryCondition;
import cn.fl.insurance.dto.InsCompTypRDTO;
import cn.fl.insurance.service.IInsCompTypRApiService;
import cn.fl.insurance.service.IInsCompTypRService;
import cn.fl.insurance.transform.InsCompTypRVOTransform;
import cn.fl.insurance.vo.InsCompTypRVO;

/**
 * @Description: 保险公司险种关系表 客户端服务层接口实现
 * 业务层方法名称前缀：
 * 新增：add*
 * 删除：remove*
 * 修改：modify*
 * 批量：batch*
 * 查询对象：select* get*
 * 查询集合：search*
 */
@Service
public class InsCompTypRServiceImpl implements IInsCompTypRService {

    /**
     * 日志
     */
    @SuppressWarnings("unused")
    private static final Logger logger = LoggerFactory.getLogger(InsCompTypRServiceImpl.class);

    /**
     * TODO 自定义 API 暴露服务
     */
    @Autowired
    private IInsCompTypRApiService insCompTypRApiService;

    @Override
    public InsCompTypRVO selectById(Long id) throws BaseException {
        if (StringUtils.isEmpty(id)) return null;
        InsCompTypRDTO dto = this.insCompTypRApiService.selectInsCompTypRById(id);
        return InsCompTypRVOTransform.toVO(dto);
    }

    @Override
    public Long add(InsCompTypRVO entity) throws BaseException {
        if (null == entity) return null;
        return this.insCompTypRApiService.addInsCompTypR(InsCompTypRVOTransform.toDTO(entity));
    }

    @Override
    public boolean removeByIds(List<Long> ids) throws BaseException {
        if (CollectionUtils.isEmpty(ids)) return false;
        return this.insCompTypRApiService.removeInsCompTypRByIds(ids, CurrentThreadContext.getCurrentUserId());
    }

    @Override
    public boolean modify(InsCompTypRVO entity) throws BaseException {
        if (null == entity) return false;
        return this.insCompTypRApiService.modifyInsCompTypR(InsCompTypRVOTransform.toDTO(entity));
    }

    @Override
    public Pager searchListPage(Pager page) throws BaseException {
        if (null == page) page = new Pager();
        return this.insCompTypRApiService.searchInsCompTypRListPage(page, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
    }

    @Override
    public List<InsCompTypRDTO> searchList(InsCompTypRQueryCondition condition) throws BaseException {
        return this.insCompTypRApiService.searchInsCompTypRList(condition);
    }

}
